<?php
	#	Описание для авто-загрузщика.
	$eeRO_auto['name']		= 'server_status';
	$eeRO_auto['desc']		= 'Позволяет узнать текущий статус';
	$eeRO_auto['version']	= 'v1.0';
	$eeRO_auto['author']	= 'Asuma';

	#	Функция статуса.
	function eeRO_check_status($ip, $port, $time)
	{
		if ( !fsockopen($ip, $port, $error, $error, $time) )
		{
			return false;
		}
		
		return true;
	}
	
	#	Модуль.
	if ( !$eeRO_cache->check('eeRO_status', 1800) )
	{
		$status = array('login' => '0', 'char' => '0', 'map' => '0', 'woe' => 0);
		
		if ( eeRO_check_status($eeRO_config->server_ip, $eeRO_config->server_lp, $eeRO_config->server_to) )
		{
			$status['login'] = '1';
		}
		
		if ( eeRO_check_status($eeRO_config->server_ip, $eeRO_config->server_cp, $eeRO_config->server_to) )
		{
			$status['char'] = '1';
		}
		
		if ( eeRO_check_status($eeRO_config->server_ip, $eeRO_config->server_mp, $eeRO_config->server_to) )
		{
			$status['map'] = '1';
		}
		$eeRO_base_ragnarok->query('SELECT `agit_status` FROM `ragsrvinfo` WHERE `index`=3 LIMIT 1');
		$temp = $eeRO_base_ragnarok->fetch();
		if ( $temp )
		{
			$status['woe'] = '1';
		}
		$eeRO_cache->set('eeRO_status', $status);
	}
	
	$eeRO_view->assign('status', $eeRO_cache->get('eeRO_status'));
